package com.hr.exception;

import com.hr.enums.ExceptionEnum;

/**
 * 自定义异常
 * ！！！必须继承RuntimeException或其子类，因为spring在进行事务管理时只会在捕获到RuntimeException时回滚，如果继承了Exception，就不会回滚
 */
public class MyException extends RuntimeException{

    private ExceptionEnum exceptionEnum;

    public MyException(ExceptionEnum exceptionEnum) {
        this.exceptionEnum = exceptionEnum;
    }

    public ExceptionEnum getExceptionEnum() {
        return exceptionEnum;
    }

    public void setExceptionEnum(ExceptionEnum exceptionEnum) {
        this.exceptionEnum = exceptionEnum;
    }

    @Override
    public String toString() {
        return "MyException{" +
                "exceptionEnum=" + exceptionEnum +
                '}';
    }
}
